import { BaseWindow } from "../../../../component/window/BaseWindow";
import { ILayer } from "../../../../mvc/interfaces/ILayer";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GuildPartyInfo } from "../info/GuildPartyInfo";
import { GButton } from "../../../../../com/mui/controls/GButton";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { Cache } from "../../../cache/Cache";
import { GTextInput } from "../../../../../com/mui/controls/GTextInput";
type int = number;
//class GuildRaiseContributeWindow
    
    export  class GuildRaiseContributeWindow extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            this.setSize(325, 255);
            this.titleHeight = 28;
            this.title = Language.getString(57463);
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createTextField(Language.getString(57464), 22, 45, 220, 20, this, GlobalStyle.textFormat6);
            this._raiseTxt = ObjCreate.createTextField(Language.getStringByParam(57465, 0), 95, 45, 220, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(57420), 22, 75, 220, 20, this, GlobalStyle.textFormat6);
            this._contiTxt = ObjCreate.createTextField("", 95, 75, 220, 20, this, GlobalStyle.textFormat6);
            ObjCreate.createTextField(Language.getString(57467), 22, 105, 220, 20, this, GlobalStyle.textFormat6);
            this._valueInput = ObjCreate.createGTextInput(95, 103, 118, 20, this);
            this._valueInput.restrict = "0-9";
            this._valueInput.addEventListener(flash.events.Event.CHANGE, this.onValueChangeHandler);
            this._descBtn = ObjCreate.createGButton(Language.getString(57430), 220, 55, 70, 24, this);
            this._descBtn.name = "desc";
            this._contriBtn = ObjCreate.createGButton(Language.getString(57468), 220, 102, 70, 24, this);
            this._descBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            this._contriBtn.addEventListener(flash.events.MouseEvent.CLICK, this.onBtnClickHandler);
            ObjCreate.createBg(17, 135, 290, 105, this);
            this._tipTxt = ObjCreate.createTextField("", 25, 145, 275, 20, this);
            this._tipTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._tipTxt.wordWrap = true;
            this._tipTxt.multiline = true;
            this._tipTxt.htmlText = Language.getString(57469);
            return;
        }

        public updateByGuildPartyInfo(arg1: GuildPartyInfo): void
        {
            if (arg1) 
            {
                this._raiseTxt.htmlText = Language.getStringByParam(57465, arg1.raiseVal);
            }
            return;
        }

        public updateByRaiseValue(arg1: int): void
        {
            this._raiseTxt.htmlText = Language.getStringByParam(57465, arg1);
            return;
        }

        public updateContribute(arg1: int): void
        {
            this._contiTxt.htmlText = Language.getStringByParam(57465, arg1);
            return;
        }

        /* internal  */onBtnClickHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc2=0;
            var loc1=(arg1.target as GButton).name;
            if (loc1 != "desc") 
            {
                loc2 = int(this._valueInput.text);
                if (loc2 > 0) 
                {
                    Dispatcher.dispatchEvent(new DataEvent(EventName.GuildPartyRaiseContribute, loc2));
                }
            }
            else 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.GuildPartyDescWindowOpen));
            }
            return;
        }

        /* internal  */onValueChangeHandler(arg1: Object /* flash.events.Event */): void
        {
            var loc1=Cache.instance.guild.myGuildInfo.contribution;
            var loc2=int(this._valueInput.text);
            if (loc2 > loc1) 
            {
                this._valueInput.text = loc1.toString();
            }
            return;
        }

        public /* override */ show(arg1: int=0, arg2: int=0): void
        {
            super.show(arg1, arg2);
            this._contiTxt.htmlText = Language.getStringByParam(57465, Cache.instance.guild.myGuildInfo.contribution);
            Dispatcher.dispatchEvent(new DataEvent(EventName.GuildPartyRaiseContribute, 0));
            return;
        }

        /* internal */ /* var */_raiseTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_contiTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_valueInput: GTextInput;

        /* internal */ /* var */_tipTxt: Object /* flash.text.TextField */;

        /* internal */ /* var */_descBtn: GButton;

        /* internal */ /* var */_contriBtn: GButton;
    }
